package edu.purdue.cs.aggr;

import java.util.HashMap;
import java.util.Map;

import edu.purdue.cs.aggr.accumulators.GrepAccumulator;
import edu.purdue.cs.aggr.accumulators.MicrobenchAccumulator;
import edu.purdue.cs.aggr.accumulators.SortAccumulator;
import edu.purdue.cs.aggr.accumulators.TopKAccumulator;
import edu.purdue.cs.aggr.accumulators.WordCountAccumulator;
import edu.purdue.cs.aggr.accumulators.YAccumulator;

public class AccumulatorFactory {

	public enum AccumulatorType {
		TOPK, SORT, GREP, WORDCOUNT, YExperiment, MICROBENCH
	}

	public static final String PARAMETER_KVAUE = "kvalue";
	public static final String PARAMETER_YVALUE = "yvalue";
	
	
	@SuppressWarnings("rawtypes")
	public static Accumulator getEmptyAccumulator(AccumulatorType type, Map<String, Object> parameters, String sourceId) {
		if (type == AccumulatorType.TOPK) {
			return new TopKAccumulator((Integer) parameters.get(PARAMETER_KVAUE), sourceId);
		} else if (type == AccumulatorType.SORT) {
			return new SortAccumulator(sourceId);
		} else if (type == AccumulatorType.GREP) {
			return new GrepAccumulator(sourceId);
		} else if (type == AccumulatorType.WORDCOUNT) {
			return new WordCountAccumulator(sourceId);
		} else if (type == AccumulatorType.YExperiment) {
			return new YAccumulator(sourceId);
		} else if (type == AccumulatorType.MICROBENCH) {
			return new MicrobenchAccumulator((Integer) parameters.get(PARAMETER_YVALUE), sourceId);
		}
		return null;
	}
}
